﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ColladaDotNet;

namespace contentviewer.ViewModel
{
	class LibGeometryViewModel : NodeViewModel
	{
		readonly  library_geometries _libGeometry;

		public LibGeometryViewModel(NodeViewModel root, NodeViewModel parent, library_geometries libGeometry)
            : base(root, parent)
        {
			_libGeometry = libGeometry;
        }

		public string Content
		{
			get { return "geometries"; }
		}

        protected override void LoadChildren()
        {
            base.LoadChildren();
			if (_libGeometry.asset != null)
				base.Children.Add(new AssetViewModel(Root, this, _libGeometry.asset));
			foreach (var geo in _libGeometry.geometry)
			{
				base.Children.Add(new GeometryViewModel(Root, this, geo));
			}
        }

		public override bool IsSelected
		{
			get
			{
				return base.IsSelected;
			}
			set
			{
				if (value == true)
					(Root as ColladaNodeViewModel).SelectedItems.Add(this);
				else
					(Root as ColladaNodeViewModel).SelectedItems.Remove(this);
				base.IsSelected = value;
			}
		}

		public override string ToString()
		{
			return this.Content;
		}
	}
}
